﻿using System;
using Jayden.Dll.Minecraft.Interfaces;

namespace Jayden.Dll.Minecraft.Model
{
	public class BlockManager
	{
		private BlockModel[] m_Blocks = new BlockModel[4096];

		private BlockManager() { }

		public static readonly BlockManager Instance = new BlockManager();

		public BlockModel this[int index] { get { return m_Blocks[index]; } }

		public void Register(int index, BlockModel block)
		{
			if (m_Blocks[index] != null)
				throw new Exception(string.Format("Block index already used {0} : '{1}'.", index, m_Blocks[index].Name));
			m_Blocks[index] = block;
		}

		public static readonly SimpleBlockModel DebugBlock = new SimpleBlockModel(4095, "Debug", 10, 1);

		public static readonly AirBlockModel Air = new AirBlockModel();
		public static readonly SimpleBlockModel Stone = new SimpleBlockModel(1, "stone", 1, 0);
		public static readonly SimpleBlockModel Dirt = new SimpleBlockModel(2, "dirt", 2, 0);
		public static readonly SimpleBlockModel CobbleStone = new SimpleBlockModel(3, "cobbleStone", 0, 1);
		public static readonly SimpleBlockModel Sand = new SimpleBlockModel(4, "sand", 2, 1);
		public static readonly SimpleBlockModel Gravel = new SimpleBlockModel(5, "gravel", 3, 1);
		public static readonly SimpleBlockModel PlankOak = new SimpleBlockModel(6, "plankOak", 4, 0);
		public static readonly SimpleBlockModel OreGold = new SimpleBlockModel(7, "oreGold", 0, 2);
		public static readonly SimpleBlockModel OreIron = new SimpleBlockModel(8, "oreIron", 1, 2);
		public static readonly SimpleBlockModel OreCoal = new SimpleBlockModel(9, "oreCoal", 2, 2);
		public static readonly SimpleBlockModel OreDiamond = new SimpleBlockModel(10, "oreDiamond", 2, 3);
		public static readonly SimpleBlockModel OreRedstone = new SimpleBlockModel(11, "oreRedstone", 3, 3);
		public static readonly SimpleBlockModel MossyCobbleStone = new SimpleBlockModel(12, "mossyCobbleStone", 4, 2);
		public static readonly SimpleBlockModel Obsidian = new SimpleBlockModel(13, "obsidian", 5, 2);
		public static readonly SimpleBlockModel BedRock = new SimpleBlockModel(14, "bedRock", 1, 1);
		public static readonly SimpleBlockModel PlankJungle = new SimpleBlockModel(15, "plankJungle", 7, 12);
		public static readonly SimpleBlockModel Glass = new SimpleBlockModel(16, "glass", 1, 3, false);
		public static readonly SimpleBlockModel Ice = new SimpleBlockModel(17, "ice", 3, 4, false);
		public static readonly SimpleBlockModel Netherrack = new SimpleBlockModel(18, "netherrack", 7, 6);
		public static readonly SimpleBlockModel WoodOak = new SimpleBlockModel(19, "woodOak", 4, 1).SetTopAndBottomImages(5, 1);
		public static readonly SimpleBlockModel StoneBricks = new SimpleBlockModel(20, "stoneBricks", 6, 3);
		public static readonly SimpleBlockModel Watermelon = new SimpleBlockModel(21, "watermelon", 8, 8).SetTopAndBottomImages(9, 8);
		public static readonly SimpleBlockModel Bookshelf = new SimpleBlockModel(22, "bookshelf", 3, 2).SetTopAndBottomImages(4, 0);
		public static readonly SimpleBlockModel LeavesOak = new SimpleBlockModel(23, "leavesOak", 4, 3, false).SetRenderFullBlock(true);
	}
}
